import { resolveDirective, withDirectives } from "vue";
export const withDirectivePower = ({
  vNode,
  bindingValue = "",
  attrs = {},
}: any = {}) => {
  const hasDirective = resolveDirective("has");
  const nodeWithDirectives: any = withDirectives(h("div", attrs, vNode), [
    [hasDirective, bindingValue],
  ]);
  return nodeWithDirectives;
};

export const withDirectiveDragModal = ({
  vNode,
  attrs = {},
  bindingValue = "",
}: any = {}) => {
  const dragModalDirective = resolveDirective("drag-modal");
  const nodeWithDirectives: any = withDirectives(h("div", attrs, vNode), [
    [dragModalDirective, bindingValue],
  ]);
  return nodeWithDirectives;
};

export const withDirectiveInput = ({
  vNode,
  bindingValue = "trim.textFilter",
  attrs = { style: {} },
}: any) => {
  const inputValidateDirective = resolveDirective("input");
  const arg = "click";
  const modifiers = {
    prevent: true,
  };
  bindingValue?.split(".")?.forEach?.((key) => {
    modifiers[key] = true;
  });
  const nodeWithDirectives: any = withDirectives(h(vNode, attrs), [
    [inputValidateDirective, bindingValue, arg, modifiers],
  ]);
  return nodeWithDirectives;
};
